/*
 * @Description:
 * @Version: 2.0
 * @Autor: zhangjx
 * @Date: 2023-05-29 17:25:55
 * @LastEditors: uphldjx 1373577124@qq.com
 * @LastEditTime: 2024-01-24 14:09:48
 */
import { useCrudStore } from '@/stores/crud'
export const baseConfig = {
	pageName: '字典项',
	dictcodes: '',
	rowKey: 'id',
	addLabel: '新增字典项',
	tipLabel: 'label',
	api: {
		index: 'sys_dict_item_page',
		add: 'sys_dict_item_add',
		edit: 'sys_dict_item_edit',
		delete: 'sys_dict_item_delete',
	},
	auth: {
		index: 'sys_dict_item_page',
		add: 'sys_dict_item_add',
		edit: 'sys_dict_item_edit',
		delete: 'sys_dict_item_delete',
	},
	dialogConfig: {
		width: '45%',
		closeOnClickModal: false,
	},
	menuBtn: [
		{
			icon: 'editor',
			label: '编辑',
			type: 'primary',
			operate: 'edit',
			auth: 'sys_dict_item_edit',
			text: true,
			show: true,
		},
		{
			icon: 'delete',
			label: '删除',
			type: 'danger',
			operate: 'delete',
			auth: 'sys_dict_item_delete',
			text: true,
			show: true,
		},
	],
	saveFormate: async (form) => {
		const { nowDict } = useCrudStore()
		return new Promise((resolve, reject) => {
			resolve({ ...form, ...nowDict })
		})
	},
	beforeOnLoadFormate: (query) => {
		const { nowDict } = useCrudStore()
		return new Promise((resolve, reject) => {
			resolve({
				...query,
				...nowDict,
			})
		})
	},
	tableConfig: {
		stripe: true,
		border: true,
		maxHeight: '80vh',
		columns: [
			{ label: '字典项标识', prop: 'dictName' },
			{ label: '字典项名称', prop: 'label' },
			{ label: '字典项数据值', prop: 'value' },
			{ label: '字典项排序', prop: 'sort' },
			{
				label: '关联字典值',
				prop: 'description',
			},
			{
				label: '回显样式',
				prop: 'remarks',
				custome: 'tag',
				dicData: [
					{ label: '成功绿', value: 'success', type: 'success' },
					{ label: '天然蓝', value: 'primary', type: 'primary' },
					{ label: '默认灰', value: 'info', type: 'info' },
					{ label: '危险红', value: 'danger', type: 'danger' },
					{ label: '警告黄', value: 'warning', type: 'warning' },
					{ label: '迷情紫', value: 'purple', type: 'purple' },
				],
			},
			{
				label: '操作',
				prop: 'menu',
				width: 280,
				fixed: 'right',
			},
		],
	},
	formConfig: {
		inline: false,
		showBtn: true,
		labelPosition: 'left',
		labelWidth: '100px',
		column: [
			{
				label: '字典项名称',
				prop: 'label',
				type: 'text',
				maxlength: '100',
				showWordLimit: true,
				span: 24,
			},
			{
				label: '字典项数据值',
				prop: 'value',
				type: 'text',
				maxlength: '50',
				showWordLimit: true,
				span: 24,
			},
			{
				label: '字典项排序',
				prop: 'sort',
				type: 'input',
				span: 24,
			},
			{
				label: '关联字典值',
				prop: 'description',
				type: 'input',
				span: 24,
			},
			{
				label: '回显样式',
				prop: 'remarks',
				type: 'select',
				dicData: [
					{ label: '成功绿', value: 'success', type: 'success' },
					{ label: '天然蓝', value: 'primary', type: 'primary' },
					{ label: '默认灰', value: 'info', type: 'info' },
					{ label: '危险红', value: 'danger', type: 'danger' },
					{ label: '警告黄', value: 'warning', type: 'warning' },
					{ label: '迷情紫', value: 'purple', type: 'purple' },
				],
				span: 24,
			},
		],
	},
}
